package com.andnnl.minPath;

/**
 * Created by chenss on 2021/5/6.
 */
public class MinAreaTest {
    public static void main(String[] args) {
        int[][] a = {
                {
                        0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0
                },
                {
                        0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0
                },
                {
                        0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0
                },
                {
                        0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0
                },
                {
                        0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0
                },
                {
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
                },
                {
                        0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0
                },
                {
                        0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0
                }
        };
        for (int i = 0; i < a.length; i++) {
            int width = a[i].length;
            for (int j = width - 1; j > 0; j--) {
                if (i > 0) {
                    if (a[i- 1][j] > 0 && a[i][j] > 0) {
                        a[i][j ] = a[i][j] + a[i-1][j];//每一行，把后面的类计前面的
                        a[i - 1][j] = 1;
                    }
                }
                if (a[i][j] > 0 && a[i][j - 1] > 0) {
                    a[i][j - 1] = a[i][j - 1] + a[i][j];//每一行，把后面的类计前面的
                    a[i][j] = 1;
                }
            }

        }
        for (int i = 0; i < a.length; i++) {
            int width = a[i].length;
            for (int j = 0; j < width; j++) {
                System.out.print(a[i][j] + ",");
            }
            System.out.println();
        }


        for (int i = 1; i < a.length; i++) {
            int width = a[i].length;
            for (int j = 0; j < width; j++) {
                if (j == 0) {
                    if (a[i][j] > 0) {

                    }

                }
            }
        }
    }
}
